﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using KetBanBonPhuong;

public partial class UserControls_PhotoDetail : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {        
        if (Request.QueryString["PhotoID"] != null)
        {
            int PhotoID = Convert.ToInt32(Request.QueryString["PhotoID"].ToString());
            Photo photo = Photo.GetInfo(PhotoID);
            Album album = Album.GetInfo(photo.AlbumID);
            // cong duong dan anh
            photoImage.ImageUrl = "http://demos.telerik.com/aspnet-ajax/Rotator/Img/Northwind/Customers/Thumbs/" + photo.FileName;
            DataTable dt = Photo.GetByAlbum(album.AlbumID);
            for (int i = 0; i < dt.Rows.Count; ++i)
            { 
                DataRow row = dt.Rows[i];
                int rowPhotoID = Convert.ToInt32(row["photo_id"].ToString());
                if (PhotoID == rowPhotoID) {
                    if (i - 1 >= 0)
                    {
                        prevLinkButton.PostBackUrl = "../PhotoDetail.aspx?PhotoID="
                            + dt.Rows[i - 1]["photo_id"].ToString();
                    }
                    else 
                    {
                        prevLinkButton.PostBackUrl = "";
                    }
                    if (i + 1 < dt.Rows.Count)
                    {
                        nextLinkButton.PostBackUrl = "../PhotoDetail.aspx?PhotoID="
                            + dt.Rows[i + 1]["photo_id"].ToString();
                    }
                    else
                    {
                        prevLinkButton.PostBackUrl = "";
                    }
                }
            }
        }
    }
}
